Two-dimensional variable length coding (2D-VLC) includes collecting or assuming the statistics of two-dimensional block transform coefficient events that are each a run of the most likely-to-occur amplitude, e.g., 0, followed by a coefficient of another amplitude. The coding includes assigning variable length codewords, e.g., optimal codes such as Huffman codes or arithmetic codes, to each event. In the description herein, 0 is assumed to be the most likely-to-occur amplitude. The collecting of or assuming statistics includes tracking the quantized non-zero-valued coefficient amplitudes and the number of zero-valued coefficients preceding the non-zero amplitude, i.e., tracking the runlengths of zeros which precedes any non-zero amplitude along a specified path, e.g., a zigzag scan path for a block of coefficients, e.g., an 8 by 8 or a 16 by 16 coefficient block. FIG. 9A shows Table 1 that illustrates the statistics tabulated as a two dimensional table. In the table, Sij is the likelihood expressed, for example, as a relative number of occurrences of an amplitude of i, i=1, 2, . . . occurring after a run of j 0's, j=0, 1, 2, . . .
A variable length codeword such as an optimal code is then assigned to each of the events that have an Sij above, with the most likely-to-occur element—typically S10 for the case of encoding a block of transform coefficients in transform coding—having the shortest number of bits, and the least occurring event coded using the longest number of bits. FIG. 9B shows as Table 2 an exemplary 2D-VLC table. In the table, Cij is the codeword used to encode the event of the combination of j consecutive 0-valued coefficients followed by a single non-zero coefficient of amplitude i, j=0, 1, . . . and i=1, 2, . . .
2D-VLC is used in common transform coding methods such as JPEG, MPEG1, MPEG2, ITU-T-261, etc., as follows. For motion video, an image is divided into blocks, e.g., 8 by 8 or 16 by 16 blocks. Each image is classified as interframe or intraframe. Interframe images are typically post motion compensation. The blocks of the image are transformed and the transform coefficients are quantized. The quantized transform coefficients are then coded along a specified path according to a 2D-VLC table. Typically, interframe and intraframe images have different 2D-VLC tables. The DC component is typically separately encoded. Furthermore, the 2D-VLC table may be truncated so that the least frequently occurring events use an escape code followed by a fixed length code. A special “EOB” end-of-block code is used to indicate the end of a block when all remaining coefficients are zero.
Still images are similarly encoded, e.g., in the same manner as an intraframe image for motion video.
A table lookup may be used to implement a 2D-VLC scheme. Prior to the table look up, the runlength of zero amplitudes preceding any non-zero amplitude and the non-zero amplitude are determined. The table look up uses a 2D table for those likely events encoded using variable length encoding. An escape code together with a fixed length code is used for relatively less likely-to-occur combinations.
As an example, consider the following ordered sequence of quantized transform coefficients:
4 −3 1 0 −2 1 0 0 1 0 0 0 −1 0 0 . . . 0.
The coded bitstream using the 2DVLC method can be represented by concatenating the following codewords:
C40+S++C30+S−+C10+S++C21+S−+C10+S++C12+S++C13+S−+CEOB.
where + denotes concatenation, S+ and S− represent positive and negative signs, respectively, and CEOB represents the end of block code.
The advantage of 2D-VLC is that both the position of each non-zero-valued coefficient as indicated by the runlength of pre-ceding zero-valued coefficients, and the quantized amplitude value are coded simultaneously as a pair using one 2D-VLC table. This may result in shorter codes on the average, i.e., codes that use fewer bits than using separate VLC tables for the position of each non-zero-valued coefficient and for its amplitude.
Because of the widespread use of image coding, many patents have been issued on different forms of VLC. U.S. Pat. No. 4,698,672 issued Oct. 6, 1987 to Wen-hsiung Chen, one of the inventors of the present invention, for example described one form of a two-dimensional variable length coding method.
Extensions and variations to the common 2D-VLC method are known. For example, the ITU H.263 compression standard defines one such variation sometimes called three-dimensional VLC (3D-VLC). See PCT patent publication WO 9318616 published Sep. 16, 1993 titled PICTURE DATA ENCODING METHOD and also the ITU-T H.263 standard. In 3D-VLC, each symbol (“event”) is a triplet (LAST, RUN, LEVEL) that includes: LAST, a binary flag that indicates whether or not the current non-zero amplitude-value is the last non-zero coefficient in the block, RUN, the run-length of zero-value coefficients that precede the current non-zero amplitude, i.e., the number of zeroes since the last non-zero coefficient amplitude, and LEVEL, the current non-zero coefficient amplitude value. Thus, there is no need for a separate EOB codeword; whether or not the non-zero coefficient is the last one is incorporated into the event. A table lookup may be used to implement 3D-VLC.
One deficiency of 2D-VLC is that every non-zero-valued coefficient needs to be accompanied by a runlength code to identify its position, in the form of the number of preceding zero-valued coefficients.
Transform compression methods have been evolving over the years from simple intraframe coding to very sophisticated predictive coding including relatively sophisticated motion compensated interframe and intraframe coding. One result of such improvements is that more and more of the quantized transform coefficients have zero-value, and that non-zero values are more and more scattered along the encoding path. While the 2D-VLC generally performs well for a mixture of clustered and scattered coefficients the advantage of the coding starts to diminish as the quantized coefficients become more scattered. This is due to the fact that the code table for the 2D-VLC will need to become sufficiently large to cover the statistics of the diminishing clustered coefficients and, as a result, the length of the codewords in the 2D-VLC table becomes longer. Using longer codewords to code the sparsely distributed (scattered) coefficients is no longer efficient and desirable.
Thus there is a need in the art for improved methods for encoding a sequence of quantized transform coefficients as encountered in image compression, where non-zero-valued coefficients are scattered, and, in particular, sparse.
In block based transform coding, the inventors have observed that there often is a region, e.g., a low frequency region along the ordering in which non-zero-valued coefficients tend to cluster, i.e., there are often a number of consecutive non-zero-valued coefficients along the low frequency region of the pre-determined path. The Extended 2D-VLC Method of above referenced incorporated by reference U.S. patent application Ser. No. 10/342,537 includes encoding repetitions of some non-zero coefficient values. One variant of the Extended 2D-VLC method provides codewords for all the possible amplitude variations of consecutive coefficients that follow a set of zero-valued coefficients. This effectively reduced the runlength to 1 for all cases. The difficulty of this approach is that there are enormous numbers of patterns that can be generated from the amplitudes of consecutive coefficients. For example, with 32 quantization levels as defined in many common video coding standards, there are in the order of 32n patterns that can be generated from n consecutive coefficients. As such, in a practical implementation, only a limited number of the most likely-to-occur non-zero amplitude values, such as 1 and 2, and a limited number of lengths of consecutive non-zero-values, such as 3 or 4 consecutive values, are regrouped for pattern matching.
Furthermore, in coding, while there may be a region where there are clusters of non-zero-valued coefficients, there is also likely to be a high frequency region where any non-zero-valued coefficients are likely to be scattered.
With these observations in mind, the Basic Hybrid VLC Method of above-mentioned incorporated by reference U.S. patent application Ser. No. 10/869,229 to inventors Chen et al. was developed to encode the position and amplitude of quantized transform coefficients separately and takes advantage of the nature of the distribution of the transform coefficients in the low frequency and high frequency regions.
In one embodiment of the above-mentioned Basic Hybrid VLC Method, two independent types of coding schemes are introduced to code the quantized coefficients along the path. A boundary is established along the path to define two regions, e.g., a low frequency region and a high frequency region. The boundary can be made adaptive to the video depending on a number of factors such as intraframe coding or interframe coding, standard definition television (SDTV) or high definition television (HDTV), complex scene or simple scene, high bit rate coding or low bit rate coding, and so forth. In one embodiment, the encoding of the quantized coefficients in the low-frequency region includes coding the positions of consecutive non-zero-valued coefficients and the positions of consecutive zero-valued coefficients using a run-length coding method of a first type and a run-length coding method of a second type. The encoding further includes coding the amplitude values and sign of the non-zero-valued coefficients. In the high-frequency region, in one embodiment, the encoding of coefficients in the high frequency region includes encoding the positions of either no consecutive zero-valued coefficients or runs of one or more consecutive zero-valued coefficients using a run-length coding method of a third type. The encoding further includes coding the amplitude values and sign of the non-zero-valued coefficients.
In one embodiment of the above-mentioned Extended Hybrid VLC Method, a coding method is used in the second region that takes into account that almost all non-zero-valued coefficients in the high frequency region are ±1. No amplitude coding is needed to encode runs of consecutive zeroes that end in a coefficient of amplitude 1. An exception (escape) code is included to encode those rare non-zero-valued coefficients that have values other than ±1.
The Extended Hybrid VLC Method of incorporated-by-reference U.S. patent application Ser. No. 10/898,654 provides an alternative coding method for the high frequency region by taking advantage of the very few amplitude values in the high frequency region, especially, for example, for low bit rate and interframe applications.
There still, however, is a need to improve improved methods for encoding the second region of the sequence of quantized transform coefficients, where non-zero-valued coefficients are scattered in, in particular, sparse.
Thus, there is a need in the art for improved methods for encoding a sequence of quantized transform coefficients as encountered in image compression in regions where non-zero-valued coefficients are scattered and sparse. This may be applicable to the whole sequence, or in different versions of hybrid coding, to only one, e.g., high frequency region.